package com.tengju.bff.interfaces.app.motivation.assembler;

import com.tengju.bff.interfaces.app.motivation.vo.UpgradeIndicatorVO;
import com.tengju.user.domain.model.star.StarIndicatorType;

import java.math.BigDecimal;

public class UpgradeIndicatorAssembler {

    public static UpgradeIndicatorVO convertToVO(StarIndicatorType starIndicatorType, BigDecimal targetIndex, BigDecimal currentIndex,Boolean result) {
        String diff = "";
        double completion = currentIndex.divide(targetIndex,2,BigDecimal.ROUND_HALF_UP).doubleValue();
        if (!result) {
            diff = starIndicatorType.upgradeCenterDiff(targetIndex.subtract(currentIndex));

        }
        String targetIndexVal = targetIndex.toString();
        String currentIndexVal = currentIndex.toString();
        if (!starIndicatorType.isAmountIndex()) {
            targetIndexVal = targetIndex.intValue() + "";
            currentIndexVal = currentIndex.intValue() + "";
        }

        return new UpgradeIndicatorVO(targetIndexVal,
                currentIndexVal,
                starIndicatorType.getUpgradeCenterDesc(),
                result,diff,completion > 1 ? 1 : completion);
    }

    public static void main(String[] args) {
        BigDecimal bigDecimal = BigDecimal.valueOf(13d);
        System.out.println(bigDecimal.toString());
    }

}
